/**
 * <p>Title: ServiceZMCLR7.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 高强
 * @version 1.0
 * <pre>Histroy:
 *          2012-01-10 上午09:32:05  高强  Create
 *</pre>
 */
package com.baosight.sczx.zm.cl.service;

import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.common.zm.basetools.TablePk;
import com.baosight.sczx.common.zm.cInterface.Department;
import com.baosight.sczx.zm.cl.domain.ZMCLReport_Assessment;

/**
 * 安全日报(数据维护)
 * 从表质量标准化工程质量和文明生产日评估
 * <p>Title: ServiceZMCP0B.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 高强
 * @version 1.0
 * <pre>Histroy:
 *          2012-01-10 上午09:32:05  高强  Create
 *</pre>
 */
public class ServiceZMCLR7 extends ServiceEPBase {
	/**
	 * 初始化
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCP70</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-01-10 上午09:32:05  高强
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo) {
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的		
		EiInfo outInfo = this.query(inInfo);
		outInfo.addBlock(Department.getInstance().getConstructionUnit("cmes.cl.department", "orgCode", "orgName", false));
		return outInfo;
	}
	
	/**
	 * 查询
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCP70</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-01-10 上午09:32:05  高强
	 * </p>
	 *
	 */
	@Override
	public EiInfo query(EiInfo inInfo) {
		StaticTools.setQueryParameters(inInfo, "fdReportId", inInfo.getString("fdReportId"), true);//添加查询条件
		EiInfo outInfo = super.query(inInfo, "ZMCLReport_Assessment.query", new ZMCLReport_Assessment());
		return outInfo;
	}
	
	/**
	 * 新增
	 * <p>Function: insert</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCP70</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *     2012-01-10 上午09:32:05  高强
	 * </p>
	 *
	 */
	@Override
	public EiInfo insert(EiInfo inInfo) {
		String keyId = TablePk.getInstance().getNextValue("T_CL_ASSESSMENT");
		inInfo.getBlock("result").setCell(0, "fdKeyId", keyId);//主键
		inInfo.getBlock("result").setCell(0, "fdReportPeopleId", UserSession.getUserId());
		inInfo.getBlock("result").setCell(0, "fdReportPeople", UserSession.getInSessionProperty("UserCname"));
		inInfo.getBlock("result").setCell(0, "fdReportDepartmentId", UserSession.getInSessionProperty("orgCode"));
		inInfo.getBlock("result").setCell(0, "fdReportDepartment", UserSession.getInSessionProperty("orgName"));
		inInfo.getBlock("result").setCell(0, "fdReportTime", StaticTools.getDateTime());
		
		EiInfo outinfo = super.insert(inInfo, "ZMCLReport_Assessment.insert");
		return outinfo;
	}

	/**
	 * 修改
	 * <p>Function: update</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCP70</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *     2012-01-10 上午09:32:05  高强
	 * </p>
	 *
	 */
	@Override
	public EiInfo update(EiInfo inInfo) {
		inInfo.getBlock("result").setCell(0, "fdReportPeopleId", UserSession.getUserId());
		inInfo.getBlock("result").setCell(0, "fdReportPeople", UserSession.getInSessionProperty("UserCname"));
		inInfo.getBlock("result").setCell(0, "fdReportDepartmentId", UserSession.getInSessionProperty("orgCode"));
		inInfo.getBlock("result").setCell(0, "fdReportDepartment", UserSession.getInSessionProperty("orgName"));
		inInfo.getBlock("result").setCell(0, "fdReportTime", StaticTools.getDateTime());
		EiInfo outInfo = super.update(inInfo, "ZMCLReport_Assessment.update");
		return outInfo;
	}
	
	/**
	 * 删除
	 * <p>Function: delete</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCP70</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-01-10 上午09:32:05  高强
	 * </p>
	 *
	 */
	@Override
	public EiInfo delete(EiInfo inInfo) {
		EiInfo _temp = super.delete(inInfo, "ZMCLReport_Assessment.delete");
        EiInfo outInfo = this.query(inInfo);
        outInfo.setMsg(_temp.getMsg());
        outInfo.setDetailMsg(_temp.getDetailMsg());
		return outInfo;
	}
}
